package com.shushan.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.shushan.login.bean.ChildBean;
import com.shushan.shushanbao.R;
import com.shushan.util.ToolUtils;

/**
 * @ClassName: BaseExerciseHeaderActivity
 * @Desciption: //带头部的练习入口界面基类
 * @author: zhangshihao
 * @date: 2018-08-15
 */
public class BaseExerciseHeaderActivity extends BaseActivity {

    private FrameLayout mContentLayout;
    private TextView tvTitle;
    private TextView tvLevelTerm;
    private TextView tvScoreCondition;
    private TextView tvTimeAward;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ScreenManager sm = ScreenManager.getInstance();
        sm.setDeepStatusBar(true,this);
        super.setContentView(R.layout.abstract_exercise_header_activity);

        initView();
    }

    private void initView(){
        mContentLayout = findViewById(R.id.content_layout);
        tvTitle = findViewById(R.id.top_title);
        tvLevelTerm = findViewById(R.id.top_right_level_term);
        tvScoreCondition = findViewById(R.id.tv_score_condition);
        tvTimeAward = findViewById(R.id.tv_time_award);
    }

    public void setHeaderText(ChildBean childBean){
        tvLevelTerm.setText(ToolUtils.getLevelTermText(childBean));
    }

    public void setHeaderText(int score, int time){
        tvScoreCondition.setText("要求："+score+"分");
        tvTimeAward.setText("奖励：手机娱乐时间"+time+"分钟");
    }

    public void setHeaderText(ChildBean childBean, int score, int time){
        tvLevelTerm.setText(ToolUtils.getLevelTermText(childBean));
        tvScoreCondition.setText("要求："+score+"分");
        tvTimeAward.setText("奖励：手机娱乐时间"+time+"分钟");
    }

    public void setHeaderTextForOralCalculate(ChildBean childBean,int total,int num,int time){
        tvLevelTerm.setText(ToolUtils.getLevelTermText(childBean));
        tvScoreCondition.setText("要求："+total+"分钟完成"+num+"题");
        tvTimeAward.setText("奖励：手机娱乐时间"+time+"分钟");
    }

    @Override
    public void setContentView(int layoutResID) {
        mContentLayout.removeAllViews();
        View.inflate(this, layoutResID, mContentLayout);
        onContentChanged();
    }

    @Override
    public void setContentView(View view) {
        mContentLayout.removeAllViews();
        mContentLayout.addView(view);
        onContentChanged();
    }

    @Override
    public void setContentView(View view, ViewGroup.LayoutParams params) {
        mContentLayout.removeAllViews();
        mContentLayout.addView(view,params);
        onContentChanged();
    }

}
